<?php // Do not delete these lines
	if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die ('Please do not load this page directly. Thanks!');

        if (!empty($post->post_password)) { // if there's a password
            if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
				?>

				<p class="nocomments">This post is password protected. Enter the password to view comments.<p>

				<?php
				return;
            }
        }

		/* This variable is for alternating comment background */
		$oddcomment = 'odd';
?>
<?php
/* ---------------------------------------------------------------------------------
|
|  $URL: http://tech2allwptheme.googlecode.com/svn/trunk/comments.php $
|  $Rev: 4 $
|  $LastChangedDate: 2008-12-11 21:00:59 +0000 (Thu, 11 Dec 2008) $
|  $LastChangedBy: ruhani.rabin $
|  $Id: comments.php 4 2008-12-11 21:00:59Z ruhani.rabin $
|
| ---------------------------------------------------------------------------------*/
?>

<!-- You can start editing here. -->

	<!-- script -->
	<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/util.js"></script>

<div id="commentsbox">

<?php if ($comments) : ?>
<?php

	/* Count the totals */
	$numPingBacks = 0;
	$numComments  = 0;
  $count=0;

	/* Loop through comments to count these totals */
	foreach ($comments as $comment) {
		if (get_comment_type() != "comment") { $numPingBacks++; }
		else { $numComments++; }
	}

?>

<?php

	/* This is a loop for printing comments */
	if ($numComments != 0) : ?>
<h2 id="comments">
	 <br /> <?php comments_number('No Responses', 'One Response', '% Responses' );?>
	  to &#8220;<?php the_title(); ?>&#8221;</h2>

<ol class="commentlist">

<?php if(function_exists('wp_list_comments')){

    if(function_exists('wp_commentnavi')) {
            echo '<div class="navigation">';
                wp_commentnavi();
            echo '</div>';
            }
    else {
            echo '<div class="navigation">';
            echo '<div class="alignleft">'.previous_comments_link().'</div>';
            echo '<div class="alignright">'.next_comments_link().'</div>';
            echo '</div>';
        };

      wp_list_comments('type=comment&callback=mytheme_comment');

    if(function_exists('wp_commentnavi')) {
            echo '<div class="navigation">';
                wp_commentnavi();
            echo '</div>';
    }
    else {
            echo '<div class="navigation">';
            echo '<div class="alignleft">'.previous_comments_link().'</div>';
            echo '<div class="alignright">'.next_comments_link().'</div>';
            echo '</div>';
        };

}
else { ?>


<?php if(function_exists('wp_commentnavi')) { ?>
            <div class="navigation">
                <?php wp_commentnavi(); ?>
            </div>
        <?php } else { ?>
            <div class="navigation">
                <div class="alignleft"><?php previous_comments_link() ?></div>
                <div class="alignright"><?php next_comments_link() ?></div>
            </div>
        <?php } ?>
<?php foreach ($comments as $comment) : ?>
<?php
$isByAuthor = false;
  if( $comment->comment_author_email == get_the_author_email()) {
    $isByAuthor = true;
  }
?>

<?php if ($comment->comment_type =="comment") : ?>
<li id="comment-<?php comment_ID() ?>">
<cite>
<?php if (function_exists('get_avatar') && get_option('show_avatars')) { echo get_avatar($comment, $size="32", $default_avatar);} ?>
<a name="comment-<?php comment_ID() ?>"></a><span ID="au_<?php comment_ID() ?>" class="author"><?php comment_author_link() ?></span>&nbsp;&nbsp;&nbsp;<span class="replycomment"><A href="javascript:void(0);" onclick="javascript:Reply('<?php comment_ID() ?>')">Reply</A></span> | <span class="quotecomment"><A href="javascript:void(0);" onclick="javascript:Quote('<?php comment_ID() ?>')">Quote</A></span><br /><span class="time"><?php comment_time() ?></span> on <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?></a> - <?php edit_comment_link('edit',' | <span class="editcomment">','</span>'); ?>
<span style="float:right;font-size:20px;width:50px;margin:-20px"><a href="#comment-<?php comment_ID() ?>" title="<?php comment_ID() ?>"><?php printf('#%1$s', ++$count); ?></a></span></cite>


<?php if($isByAuthor)
  { echo '<div class="authorcommenttext">';}
  else
  { echo '<div class="commenttext">';};
?>
<span ID="co_<?php comment_ID() ?>">
<?php comment_text() ?>
</span>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
	<?php endif; ?>

</li>
<?php endforeach; /* end for each comment */ ?>
<?php if(function_exists('wp_commentnavi')) { ?>
            <div class="navigation">
                <?php wp_commentnavi(); ?>
            </div>
        <?php } else { ?>
            <div class="navigation">
                <div class="alignleft"><?php previous_comments_link() ?></div>
                <div class="alignright"><?php next_comments_link() ?></div>
            </div>
        <?php } ?>	<?php }; ?>

</ol>



	<?php endif; ?>

<?php

	/* This is a loop for printing trackbacks if there are any */
	if ($numPingBacks != 0) : ?>

	<ol class="tblist" style="list-style:none;">

<li><h2><?php _e($numPingBacks); ?> Trackback(s)</h2></li>

<?php foreach ($comments as $comment) : ?>
<?php if ($comment->comment_type !="comment") : ?>

	<li id="comment-<?php comment_ID() ?>">
		<?php comment_date('M j, Y') ?>: <?php comment_author_link() ?>
		<?php if ($comment->comment_approved == '0') : ?>
		<em>Your comment is awaiting moderation.</em>
		<?php endif; ?>
	</li>

	<?php if('odd'==$thiscomment) { $thiscomment = 'even'; } else { $thiscomment = 'odd'; } ?>

<?php endif; endforeach; ?>

	</ol>

<?php endif; ?>

<?php else :

	/* No comments at all means a simple message instead */
?>

<?php endif; ?>

<?php if (comments_open()) : ?>

	<?php if (get_option('comment_registration') && !$user_ID ) : ?>
		<p id="comments-blocked">You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=
		<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
	<?php else : ?>

	<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
  <div id="respond">
	<h2>Post a Comment</h2>
  <div id="cancel-comment-reply">
	<small></small>
</div>
  <?php if ($user_ID) : ?>

	<p>You are logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php">
		<?php echo $user_identity; ?></a>. To logout, <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">click here</a>.
	</p>

<?php else : ?>

<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>

<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
<label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>

<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
	<?php
/****** Math Comment Spam Protection Plugin ******/
if ( function_exists('math_comment_spam_protection') ) {
	$mcsp_info = math_comment_spam_protection();
?> 	<p><input type="text" name="mcspvalue" id="mcspvalue" value="" size="22" tabindex="4" />
	<label for="mcspvalue"><small>Spam protection: Sum of <?php echo $mcsp_info['operand1'] . ' + ' . $mcsp_info['operand2'] . ' ?' ?></small></label>
	<input type="hidden" name="mcspinfo" value="<?php echo $mcsp_info['result']; ?>" />
</p>
<?php } // if function_exists... ?>
	<?php endif; ?>

		<p><textarea name="comment" id="comment" cols="5" rows="10" tabindex="4"></textarea></p>

		<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
		<!-- <input type="hidden" name="comment_post_ID" value="<?php //echo $id; ?>" /> --></p>
    <?php comment_id_fields(); ?>

	<?php do_action('comment_form', $post->ID); ?>

	</form>
  </div>

<?php endif; // If registration required and not logged in ?>

<?php else : // Comments are closed ?>
	<!-- <p id="comments-closed">Sorry, comments for this entry are closed at this time.</p> -->
<?php endif; ?></div>